
using System;

namespace GtkControls
{
    
    
    public static class StringUtils
    {
        /// <summary>
        /// Get bytes in human-readable form.
        /// </summary>
        public static string FormatBytes(long bytes)
        {
            double dbytes = bytes;
            if(dbytes < 1024)
                return String.Format("{0:0} b", dbytes);
            
            dbytes = dbytes/1024;
            if(dbytes < 1024)
                return String.Format("{0:0.0} kB", dbytes);
            
            dbytes = dbytes/1024;
            if(dbytes < 1024)
                return String.Format("{0:0.0} MB", dbytes);
           
            dbytes = dbytes/1024;
            
            return String.Format("{0:0.0} GB", dbytes);
        }
    }
}
